import {defineConfig, loadEnv} from 'vite'
import vue from '@vitejs/plugin-vue'

const {resolve} = require('path')
// https://vitejs.dev/config/
export default ({mode}) => {
    const config = loadEnv(mode, './')
    return defineConfig({
        base: config.VITE_BASE_URL,
        resolve: {
            alias: {
                "@": resolve(__dirname, "./src"),
                "components": resolve(__dirname, "./src/components"),
                "styles": resolve(__dirname, "./src/styles"),
                "utils": resolve(__dirname, "./src/utils"),
            }
        },
        plugins: [
            vue()],
        server: {
            port: 3339,
            proxy: {
                '/portal': {
                    target: 'http://122.114.204.42:6891/portal',
                    changeOrigin: true,
                    rewrite: (path) => path.replace(/^\/portal/, '')

                },
                // '/api': {
                //     target: 'http://122.114.204.42:6891',
                //     changeOrigin: true,
                //     rewrite: (path) => path.replace(/^\/api/, '')
                // }
            }
        }
    })
}
